/*java jdk 1.7+
# -*- coding: utf-8 -
'''
Created on 2020年05月10日
@author: zxyong 13738196011
'''*/

package com.zxy.business;

import java.io.BufferedOutputStream;
import java.io.IOException;
import java.io.OutputStreamWriter;
import java.io.PrintWriter;
import java.lang.reflect.Field;
import java.net.Socket;
import java.util.ArrayList;
import java.util.Enumeration;
import java.util.Hashtable;

import com.zxy.adminlog.UsAdmin_Log;
import com.zxy.common.Com_Fun;
import com.zxy.common.Com_Para;
import com.zxy.common.DbConfigSelf;
import com.zxy.common.ParamName_InterFace;

public class Analyse_Data
{
	public String TemChildNode = "";
	public int iNum = 0;
	
	// 作为服务端接收到数据包 iServ 是否作为服务端接收到数据
	public String SubAnalyseRecBytes(int iLength, char[] Bytes, Socket mServSocket, Boolean iServ, String strIP) throws Exception
	{
		for(Enumeration<String> sm = Com_Para.htChildNode.keys();sm.hasMoreElements();)
		{
			TemChildNode = sm.nextElement();
			if(!java.util.Objects.equals(Com_Para.htChildNode.get(TemChildNode),null)
					&& Com_Para.htChildNode.get(TemChildNode).toString().equals("servSocket"
							+ mServSocket.getInetAddress().getHostAddress()))
			{
				break;
			}else
			{
				TemChildNode = "";
			}
		}

		StringBuilder strResult = new StringBuilder(new String(Bytes));
		// for(int i = 0;i < iLength;i++)
		// {
		// strResult.append(Bytes[i]);
		// }
		// 作为服务端接收数据拦截器
		if(!Com_Para.ServerREFLECT_IN_CLASS.equals(""))
		{
			String temContinue = "";
			StringBuilder temResult = new StringBuilder();
			try
			{
				Class<?> objC = Class.forName(Com_Para.ServerREFLECT_IN_CLASS);
				ParamName_InterFace pni = (ParamName_InterFace) objC.newInstance();
				for(Field field: pni.getClass().getDeclaredFields())
				{
					field.setAccessible(true);
					if(field.getName().equals("strResult"))
						field.set(pni,strResult);
					else if(field.getName().equals("strIP"))
						field.set(pni,strIP);
					else if(field.getName().equals("bytesResult"))
						field.set(pni,Bytes);
				}
				pni.init_start();
				for(Field field: pni.getClass().getDeclaredFields())
				{
					if(field.getName().equals("strResult"))
					{
						Object fieldGetName = Com_Fun.getFieldValueByName(field.getName(),pni);
						if(!fieldGetName.toString().equals(""))
						{
							temResult.append(fieldGetName.toString());
						}
					}else if(field.getName().equals("strContinue"))
					{
						Object fieldGetName = Com_Fun.getFieldValueByName(field.getName(),pni);
						if(fieldGetName.toString().equals("1"))
						{
							temContinue = fieldGetName.toString();
						}
					}
				}

				if(temContinue.equals("1"))
				{
					Com_Fun.SendSocket(temResult,mServSocket);
					return "";
				}else if(!temContinue.equals("0"))
				{
					return "";
				}
			}
			catch(Exception e)
			{
				Com_Fun.debug_in(e,this.toString(),"作为服务端接收数据拦截器获取失败!"
						+ strResult.toString());
			}
		}

		String[] strALength = strResult.toString().split("\n");
		// 接收数据包
		for(String strAryT: strALength)
		{
			strAryT = strAryT.replace("\r","").replace("\n","");
			Hashtable<String, String> ht = null;
			ArrayList<String> al = new ArrayList<String>();

			if(DbConfigSelf.UserDebug.indexOf("|10|") != -1)
			{
				StringBuilder sb = new StringBuilder();
				sb.append("接收到客户端数据:" + strAryT);
				UsAdmin_Log uL = new UsAdmin_Log(Com_Para.ApplicationPath,sb);
				uL.WriteLogSub("RecDataServer");
			}
			// 协议含包头和包尾
			if(strAryT.length() > 3 && strAryT.indexOf("@##") == 0
					&& strAryT.indexOf("##@") == strAryT.length() - 3)
			{
				// 获取子设备Child_Node
				if(strAryT.indexOf("@##ST=01") != -1)
				{
					ht = GetPackageInfo(strAryT);
					Com_Para.htChildNode.put(ht.get("CHILD_NODE").toString(),"servSocket"
							+ mServSocket.getInetAddress().getHostAddress());
				}
				// 获取业务数据
				else if(strAryT.indexOf("@##ST=03") != -1)
				{
					ht = GetPackageInfo(strAryT);
					if(!TemChildNode.equals(""))
						Com_Para.htChildInfo.put(TemChildNode,ht.get("VALUE").toString());
					Com_Para.htTempChildInfo.put(ht.get("CHILD_NODE").toString(),"");
				}
				// 直接获取业务数据
				else if(strAryT.indexOf("@##ST=04") != -1)
				{
					ht = GetPackageInfo(strAryT);
					Query_Data gd = new Query_Data();
					for(int in = 1;in < 101;in++)
					{
						String strVS = "";
						if(!java.util.Objects.equals(ht.get("param_value"
								+ String.valueOf(in)),null))
						{
							strVS = (String) ht.get("param_value"
									+ String.valueOf(in));
						}else
							break;
						al.add(in - 1,strVS);
					}
					String sub_code = java.util.Objects.equals(ht.get("sub_code"),null) ? "" : (String) ht.get("sub_code");
					String sub_usercode = java.util.Objects.equals(ht.get("sub_usercode"),null) ? "" : (String) ht.get("sub_usercode");
					String delay_data = java.util.Objects.equals(ht.get("delay_data"),null) ? "" : (String) ht.get("delay_data");
					String delay_code = java.util.Objects.equals(ht.get("delay_code"),null) ? "" : (String) ht.get("delay_code");
					String param_name = java.util.Objects.equals(ht.get("param_name"),null) ? "" : (String) ht.get("param_name");
					StringBuilder sbd = gd.GetDataList(sub_code,sub_usercode,param_name,al,new StringBuilder(strAryT),delay_data,delay_code,strIP,ht);
					Send03(sbd.toString(),mServSocket);
				}
			}
			// 协议含包头，无包尾
			else if(strAryT.length() > 3 && strAryT.indexOf("@##") == 0
					&& strAryT.indexOf("##@") == -1)
			{
				ht = GetPackageInfo(strAryT);
				if(!java.util.Objects.equals(TemChildNode,null))
					Com_Para.htTempChildInfo.put(TemChildNode,ht.get("VALUE").toString());
			}
			// 协议无包头,含包尾
			else if(strAryT.indexOf("@##") == -1
					&& strAryT.indexOf("##@") != -1)
			{
				// 获取子设备Child_Node
				if(!TemChildNode.equals(""))
					Com_Para.htChildInfo.put(TemChildNode,Com_Para.htTempChildInfo.get(TemChildNode)
							+ strAryT.replace("##@",""));
				Com_Para.htTempChildInfo.put(TemChildNode,"");
				// 直接获取业务数据
				if(strAryT.indexOf("@##ST=04") != -1)
				{
					ht = GetPackageInfo(strAryT);
					Query_Data gd = new Query_Data();
					for(int in = 1;in < 101;in++)
					{
						String strVS = "";
						if(!java.util.Objects.equals((ht.get("param_value"
								+ String.valueOf(in))),null))
						{
							strVS = (String) ht.get("param_value"
									+ String.valueOf(in));
						}else
							break;
						al.add(in - 1,strVS);
					}
					String sub_code = java.util.Objects.equals((ht.get("sub_code")),null) ? "" : (String) ht.get("sub_code");
					String sub_usercode = java.util.Objects.equals((ht.get("sub_usercode")),null) ? "" : (String) ht.get("sub_usercode");
					String delay_data = java.util.Objects.equals((ht.get("delay_data")),null) ? "" : (String) ht.get("delay_data");
					String delay_code = java.util.Objects.equals((ht.get("delay_code")),null) ? "" : (String) ht.get("delay_code");
					String param_name = java.util.Objects.equals((ht.get("param_name")),null) ? "" : (String) ht.get("param_name");
					StringBuilder sbd = gd.GetDataList(sub_code,sub_usercode,param_name,al,new StringBuilder(strAryT),delay_data,delay_code,strIP,ht);
					Send03(sbd.toString(),mServSocket);
				}
			}
			// 负氧离子
			else if(strAryT.indexOf("M1033") == 0
					&& strAryT.lastIndexOf("V") == strAryT.length() - 1
					&& strAryT.length() > 66)
			{
				ht = GetPackageInfoFlz_1(strAryT);
				al.add(ht.get("param_value1"));
				al.add(ht.get("param_value2"));
				al.add(ht.get("param_value3"));
				al.add(ht.get("param_value4"));
				al.add(ht.get("param_value5"));
				al.add(ht.get("param_value6"));
				al.add(ht.get("param_value7"));
				al.add(ht.get("param_value8"));
				Query_Data gd = new Query_Data();
				String input_url = java.util.Objects.equals(ht.get("input_url"),null) ? "" : (String) ht.get("input_url");
				String sub_code = java.util.Objects.equals(ht.get("sub_code"),null) ? "" : (String) ht.get("sub_code");
				String sub_usercode = java.util.Objects.equals(ht.get("sub_usercode"),null) ? "" : (String) ht.get("sub_usercode");
				String param_name = java.util.Objects.equals(ht.get("param_name"),null) ? "" : (String) ht.get("param_name");
				gd.GetDataList(sub_code,sub_usercode,param_name,al,new StringBuilder(input_url),"","",strIP,ht);
			}
			// 协议包中间
			else if(!strAryT.equals("") && strAryT.indexOf("@##") == -1
					&& strAryT.indexOf("##@") == -1)
			{
				if(!TemChildNode.equals(""))
					Com_Para.htTempChildInfo.put(TemChildNode,Com_Para.htTempChildInfo.get(TemChildNode)
							+ strAryT.replace("##@",""));
			}
		}
		return "";
	}

	// 作为服务端接收到数据包 iServ 是否作为服务端接收到数据
	public String SubAnalyseRecBytes(int iLength, byte[] Bytes, Socket mServSocket, Boolean iServ, String strIP) throws Exception
	{
		for(Enumeration<String> sm = Com_Para.htChildNode.keys();sm.hasMoreElements();)
		{
			TemChildNode = sm.nextElement();
			if(!java.util.Objects.equals(Com_Para.htChildNode.get(TemChildNode),null)
					&& Com_Para.htChildNode.get(TemChildNode).toString().equals("servSocket"
							+ mServSocket.getInetAddress().getHostAddress()))
			{
				break;
			}else
			{
				TemChildNode = "";
			}
		}

		StringBuilder strResult = new StringBuilder(new String(Bytes,Com_Para.U_CODE));
		if(true){
			//原始接收数据
			com.zxy.adminlog.UsAdmin_Log uL = new com.zxy.adminlog.UsAdmin_Log(Com_Para.ApplicationPath,strResult,"RecCharInfo");
			uL.WriteLog();
		}
		// 作为服务端接收数据拦截器

//		if(!Com_Para.ServerREFLECT_IN_CLASS.equals("com.utils.hac_auto.A01_HAC_AUTO_reflect")){
//			com.utils.hac_auto.A01_HAC_AUTO_reflect a01_har = new com.utils.hac_auto.A01_HAC_AUTO_reflect();
//			a01_har.strResult = strResult;
//			a01_har.strIP = strIP;
//			a01_har.init_start();
//		}
//		else 
			if(!Com_Para.ServerREFLECT_IN_CLASS.equals(""))
		{
			String temContinue = "";
			StringBuilder temResult = new StringBuilder();
			try
			{
				Class<?> objC = Class.forName(Com_Para.ServerREFLECT_IN_CLASS.split(";")[this.iNum]);
				ParamName_InterFace pni = (ParamName_InterFace) objC.newInstance();
				for(Field field: pni.getClass().getDeclaredFields())
				{
					field.setAccessible(true);
					if(field.getName().equals("strResult"))
						field.set(pni,strResult);
					else if(field.getName().equals("strIP"))
						field.set(pni,strIP);
					else if(field.getName().equals("bytesResult"))
						field.set(pni,Bytes);
				}
				pni.init_start();
				for(Field field: pni.getClass().getDeclaredFields())
				{
					if(field.getName().equals("strResult"))
					{
						Object fieldGetName = Com_Fun.getFieldValueByName(field.getName(),pni);
						if(!fieldGetName.toString().equals(""))
						{
							temResult.append(fieldGetName.toString());
						}
					}else if(field.getName().equals("strContinue"))
					{
						Object fieldGetName = Com_Fun.getFieldValueByName(field.getName(),pni);
						if(fieldGetName.toString().equals("1"))
						{
							temContinue = fieldGetName.toString();
						}
					}
				}

				if(temContinue.equals("1"))
				{
					Com_Fun.SendSocket(temResult,mServSocket);
					return "";
				}else if(!temContinue.equals("0"))
				{
					return "";
				}
			}
			catch(Exception e)
			{
				Com_Fun.debug_in(e,this.toString(),"作为服务端接收数据拦截器获取失败!"
						+ strResult.toString());
			}
		}

		String[] strALength = strResult.toString().split("\n");
		// 接收数据包
		for(String strAryT: strALength)
		{
			strAryT = strAryT.replace("\r","").replace("\n","");
			Hashtable<String, String> ht = null;
			ArrayList<String> al = new ArrayList<String>();

			if(DbConfigSelf.UserDebug.indexOf("|10|") != -1)
			{
				StringBuilder sb = new StringBuilder();
				sb.append("接收到客户端数据:" + strAryT);
				UsAdmin_Log uL = new UsAdmin_Log(Com_Para.ApplicationPath,sb);
				uL.WriteLogSub("RecDataServer");
			}
			// 协议含包头和包尾
			if(strAryT.length() > 3 && strAryT.indexOf("@##") == 0
					&& strAryT.indexOf("##@") == strAryT.length() - 3)
			{
				// 获取子设备Child_Node
				if(strAryT.indexOf("@##ST=01") != -1)
				{
					ht = GetPackageInfo(strAryT);
					Com_Para.htChildNode.put(ht.get("CHILD_NODE").toString(),"servSocket"
							+ mServSocket.getInetAddress().getHostAddress());
				}
				// 获取业务数据
				else if(strAryT.indexOf("@##ST=03") != -1)
				{
					ht = GetPackageInfo(strAryT);
					if(!TemChildNode.equals(""))
						Com_Para.htChildInfo.put(TemChildNode,ht.get("VALUE").toString());
					Com_Para.htTempChildInfo.put(ht.get("CHILD_NODE").toString(),"");
				}
				// 直接获取业务数据
				else if(strAryT.indexOf("@##ST=04") != -1)
				{
					ht = GetPackageInfo(strAryT);
					Query_Data gd = new Query_Data();
					for(int in = 1;in < 101;in++)
					{
						String strVS = "";
						if(!java.util.Objects.equals(ht.get("param_value"
								+ String.valueOf(in)),null))
						{
							strVS = (String) ht.get("param_value"
									+ String.valueOf(in));
						}else
							break;
						al.add(in - 1,strVS);
					}
					String sub_code = java.util.Objects.equals(ht.get("sub_code"),null) ? "" : (String) ht.get("sub_code");
					String sub_usercode = java.util.Objects.equals(ht.get("sub_usercode"),null) ? "" : (String) ht.get("sub_usercode");
					String delay_data = java.util.Objects.equals(ht.get("delay_data"),null) ? "" : (String) ht.get("delay_data");
					String delay_code = java.util.Objects.equals(ht.get("delay_code"),null) ? "" : (String) ht.get("delay_code");
					String param_name = java.util.Objects.equals(ht.get("param_name"),null) ? "" : (String) ht.get("param_name");
					StringBuilder sbd = gd.GetDataList(sub_code,sub_usercode,param_name,al,new StringBuilder(strAryT),delay_data,delay_code,strIP,ht);
					Send03(sbd.toString(),mServSocket);
				}
			}
			// 协议含包头，无包尾
			else if(strAryT.length() > 3 && strAryT.indexOf("@##") == 0
					&& strAryT.indexOf("##@") == -1)
			{
				ht = GetPackageInfo(strAryT);
				if(!java.util.Objects.equals(TemChildNode,null))
					Com_Para.htTempChildInfo.put(TemChildNode,ht.get("VALUE").toString());
			}
			// 协议无包头,含包尾
			else if(strAryT.indexOf("@##") == -1
					&& strAryT.indexOf("##@") != -1)
			{
				// 获取子设备Child_Node
				if(!TemChildNode.equals(""))
					Com_Para.htChildInfo.put(TemChildNode,Com_Para.htTempChildInfo.get(TemChildNode)
							+ strAryT.replace("##@",""));
				Com_Para.htTempChildInfo.put(TemChildNode,"");
				// 直接获取业务数据
				if(strAryT.indexOf("@##ST=04") != -1)
				{
					ht = GetPackageInfo(strAryT);
					Query_Data gd = new Query_Data();
					for(int in = 1;in < 101;in++)
					{
						String strVS = "";
						if(!java.util.Objects.equals((ht.get("param_value"
								+ String.valueOf(in))),null))
						{
							strVS = (String) ht.get("param_value"
									+ String.valueOf(in));
						}else
							break;
						al.add(in - 1,strVS);
					}
					String sub_code = java.util.Objects.equals((ht.get("sub_code")),null) ? "" : (String) ht.get("sub_code");
					String sub_usercode = java.util.Objects.equals((ht.get("sub_usercode")),null) ? "" : (String) ht.get("sub_usercode");
					String delay_data = java.util.Objects.equals((ht.get("delay_data")),null) ? "" : (String) ht.get("delay_data");
					String delay_code = java.util.Objects.equals((ht.get("delay_code")),null) ? "" : (String) ht.get("delay_code");
					String param_name = java.util.Objects.equals((ht.get("param_name")),null) ? "" : (String) ht.get("param_name");
					StringBuilder sbd = gd.GetDataList(sub_code,sub_usercode,param_name,al,new StringBuilder(strAryT),delay_data,delay_code,strIP,ht);
					Send03(sbd.toString(),mServSocket);
				}
			}
			// 协议包中间
			else if(!strAryT.equals("") && strAryT.indexOf("@##") == -1
					&& strAryT.indexOf("##@") == -1)
			{
				if(!TemChildNode.equals(""))
					Com_Para.htTempChildInfo.put(TemChildNode,Com_Para.htTempChildInfo.get(TemChildNode)
							+ strAryT.replace("##@",""));
			}
		}
		return "";
	}

	// 作为客户端接收到服务端请求数据包,字节形式
	public String SubClientRecBytes(int iLength, byte[] Bytes, Socket mServSocket, Boolean iServ, String strIP) throws Exception
	{
		StringBuilder strResult = new StringBuilder(new String(Bytes,Com_Para.U_CODE));
		// 作为客户端接收数据拦截器
		if(!Com_Para.ClientREFLECT_IN_CLASS.equals(""))
		{
			String temContinue = "";
			try
			{
				Class<?> objC = Class.forName(Com_Para.ClientREFLECT_IN_CLASS);
				ParamName_InterFace pni = (ParamName_InterFace) objC.newInstance();
				for(Field field: pni.getClass().getDeclaredFields())
				{
					field.setAccessible(true);
					if(field.getName().equals("strResult"))
						field.set(pni,strResult);
					else if(field.getName().equals("strIP"))
						field.set(pni,strIP);
					else if(field.getName().equals("bytesResult"))
						field.set(pni,Bytes);
				}
				pni.init_start();
				for(Field field: pni.getClass().getDeclaredFields())
				{
					if(field.getName().equals("strSend"))
					{
						Object fieldGetName = Com_Fun.getFieldValueByName(field.getName(),pni);
						if(!fieldGetName.toString().equals(""))
						{
						}
					}else if(field.getName().equals("strResult"))
					{
						Object fieldGetName = Com_Fun.getFieldValueByName(field.getName(),pni);
						if(!fieldGetName.toString().equals(""))
						{
						}
					}else if(field.getName().equals("strContinue"))
					{
						Object fieldGetName = Com_Fun.getFieldValueByName(field.getName(),pni);
						if(!fieldGetName.toString().equals(""))
						{
							temContinue = fieldGetName.toString();
						}
					}
				}

				if(temContinue.equals("0"))
					return "";
			}
			catch(Exception e)
			{
				Com_Fun.debug_in(e,this.toString(),"作为客户端接收数据拦截器获取失败!"
						+ strResult.toString());
			}
		}

		// 接收数据包
		for(String strAryT: strResult.toString().split("\n"))
		{
			strAryT = strAryT.replace("\r","").replace("\n","");
			if(DbConfigSelf.UserDebug.indexOf("|10|") != -1)
			{
				StringBuilder sb = new StringBuilder();
				sb.append("接收到服务端数据:" + strAryT
						+ Com_Fun.DateTimeStr("yyyy-MM-dd HH:mm:ss:SSS"));
				UsAdmin_Log uL = new UsAdmin_Log(Com_Para.ApplicationPath,sb);
				uL.WriteLogSub("RecDataClient");
			}
			Hashtable<String, String> htParam = null;
			ArrayList<String> al = new ArrayList<String>();
			if(strAryT.indexOf("@##") == 0
					&& strAryT.indexOf("##@") == strAryT.length() - 3)
			{
				// 获取业务数据
				if(strAryT.indexOf("@##ST=02") != -1)
				{
					htParam = GetPackageInfo(strAryT);
					Query_Data gd = new Query_Data();
					for(int in = 1;in < 101;in++)
					{
						String strVS = "";
						if(!java.util.Objects.equals(htParam.get("param_value"
								+ String.valueOf(in)),null))
						{
							strVS = (String) htParam.get("param_value"
									+ String.valueOf(in));
						}else
							break;
						al.add(in - 1,strVS);
					}
					String sub_code = java.util.Objects.equals(htParam.get("sub_code"),null) ? "" : (String) htParam.get("sub_code");
					String sub_usercode = java.util.Objects.equals(htParam.get("sub_usercode"),null) ? "" : (String) htParam.get("sub_usercode");
					String delay_data = java.util.Objects.equals(htParam.get("delay_data"),null) ? "" : (String) htParam.get("delay_data");
					String delay_code = java.util.Objects.equals(htParam.get("delay_code"),null) ? "" : (String) htParam.get("delay_code");
					String param_name = java.util.Objects.equals(htParam.get("param_name"),null) ? "" : (String) htParam.get("param_name");
					StringBuilder sbd = gd.GetDataList(sub_code,sub_usercode,param_name,al,new StringBuilder(strAryT),delay_data,delay_code,strIP,htParam);
					Send03(sbd.toString(),mServSocket);
				}
			}
			// 协议无包头,含包尾
			else if(strAryT.indexOf("@##") == -1
					&& strAryT.indexOf("##@") != -1)
			{
				// 获取业务数据
				if(strAryT.indexOf("@##ST=02") != -1)
				{
					htParam = GetPackageInfo(strAryT.replace("\r","").replace("\n",""));
					Query_Data gd = new Query_Data();
					for(int in = 1;in < 101;in++)
					{
						String strVS = "";
						if(!java.util.Objects.equals(htParam.get("param_value"
								+ String.valueOf(in)),null))
						{
							strVS = (String) htParam.get("param_value"
									+ String.valueOf(in));
						}else
							break;
						al.add(in - 1,strVS);
					}
					String sub_code = java.util.Objects.equals(htParam.get("sub_code"),null) ? "" : (String) htParam.get("sub_code");
					String sub_usercode = java.util.Objects.equals(htParam.get("sub_usercode"),null) ? "" : (String) htParam.get("sub_usercode");
					String delay_data = java.util.Objects.equals(htParam.get("delay_data"),null) ? "" : (String) htParam.get("delay_data");
					String delay_code = java.util.Objects.equals(htParam.get("delay_code"),null) ? "" : (String) htParam.get("delay_code");
					String param_name = java.util.Objects.equals(htParam.get("param_name"),null) ? "" : (String) htParam.get("param_name");
					StringBuilder sbd = gd.GetDataList(sub_code,sub_usercode,param_name,al,new StringBuilder(strAryT),delay_data,delay_code,strIP,htParam);
					Send03(sbd.toString(),mServSocket);
				}
			}else if(strAryT.indexOf("@##") == -1
					&& strAryT.indexOf("##@") == -1)
			{
			}
		}
		return "";
	}

	// 作为客户端接收到服务端请求数据包，字符char[]形式
	public String SubClientRecBytes(int iLength, char[] Bytes, Socket mServSocket, Boolean iServ, String strIP) throws Exception
	{
		StringBuilder strResult = new StringBuilder(String.valueOf(Bytes));
		// for(int i = 0;i < iLength;i++)
		// {
		// strResult.append(Bytes[i]);
		// }
		// 作为客户端接收数据拦截器
		if(!Com_Para.ClientREFLECT_IN_CLASS.equals(""))
		{
			String temContinue = "";
			try
			{
				Class<?> objC = Class.forName(Com_Para.ClientREFLECT_IN_CLASS);
				ParamName_InterFace pni = (ParamName_InterFace) objC.newInstance();
				for(Field field: pni.getClass().getDeclaredFields())
				{
					field.setAccessible(true);
					if(field.getName().equals("strResult"))
						field.set(pni,strResult);
					else if(field.getName().equals("strIP"))
						field.set(pni,strIP);
					else if(field.getName().equals("bytesResult"))
						field.set(pni,Bytes);
				}
				pni.init_start();
				for(Field field: pni.getClass().getDeclaredFields())
				{
					if(field.getName().equals("strSend"))
					{
						Object fieldGetName = Com_Fun.getFieldValueByName(field.getName(),pni);
						if(!fieldGetName.toString().equals(""))
						{
						}
					}else if(field.getName().equals("strResult"))
					{
						Object fieldGetName = Com_Fun.getFieldValueByName(field.getName(),pni);
						if(!fieldGetName.toString().equals(""))
						{
						}
					}else if(field.getName().equals("strContinue"))
					{
						Object fieldGetName = Com_Fun.getFieldValueByName(field.getName(),pni);
						if(!fieldGetName.toString().equals(""))
						{
							temContinue = fieldGetName.toString();
						}
					}
				}

				if(temContinue.equals("0"))
					return "";
			}
			catch(Exception e)
			{
				Com_Fun.debug_in(e,this.toString(),"作为客户端接收数据拦截器获取失败!"
						+ strResult.toString());
			}
		}

		// 接收数据包
		for(String strAryT: strResult.toString().split("\n"))
		{
			strAryT = strAryT.replace("\r","").replace("\n","");
			if(DbConfigSelf.UserDebug.indexOf("|10|") != -1)
			{
				StringBuilder sb = new StringBuilder();
				sb.append("接收到服务端数据:" + strAryT
						+ Com_Fun.DateTimeStr("yyyy-MM-dd HH:mm:ss:SSS"));
				UsAdmin_Log uL = new UsAdmin_Log(Com_Para.ApplicationPath,sb);
				uL.WriteLogSub("RecDataClient");
			}
			Hashtable<String, String> htParam = null;
			ArrayList<String> al = new ArrayList<String>();
			if(strAryT.indexOf("@##") == 0
					&& strAryT.indexOf("##@") == strAryT.length() - 3)
			{
				// 获取业务数据
				if(strAryT.indexOf("@##ST=02") != -1)
				{
					htParam = GetPackageInfo(strAryT);
					Query_Data gd = new Query_Data();
					for(int in = 1;in < 101;in++)
					{
						String strVS = "";
						if(!java.util.Objects.equals(htParam.get("param_value"
								+ String.valueOf(in)),null))
						{
							strVS = (String) htParam.get("param_value"
									+ String.valueOf(in));
						}else
							break;
						al.add(in - 1,strVS);
					}
					String sub_code = java.util.Objects.equals(htParam.get("sub_code"),null) ? "" : (String) htParam.get("sub_code");
					String sub_usercode = java.util.Objects.equals(htParam.get("sub_usercode"),null) ? "" : (String) htParam.get("sub_usercode");
					String delay_data = java.util.Objects.equals(htParam.get("delay_data"),null) ? "" : (String) htParam.get("delay_data");
					String delay_code = java.util.Objects.equals(htParam.get("delay_code"),null) ? "" : (String) htParam.get("delay_code");
					String param_name = java.util.Objects.equals(htParam.get("param_name"),null) ? "" : (String) htParam.get("param_name");
					StringBuilder sbd = gd.GetDataList(sub_code,sub_usercode,param_name,al,new StringBuilder(strAryT),delay_data,delay_code,strIP,htParam);
					Send03(sbd.toString(),mServSocket);
				}
			}
			// 协议无包头,含包尾
			else if(strAryT.indexOf("@##") == -1
					&& strAryT.indexOf("##@") != -1)
			{
				// 获取业务数据
				if(strAryT.indexOf("@##ST=02") != -1)
				{
					htParam = GetPackageInfo(strAryT.replace("\r","").replace("\n",""));
					Query_Data gd = new Query_Data();
					for(int in = 1;in < 101;in++)
					{
						String strVS = "";
						if(!java.util.Objects.equals(htParam.get("param_value"
								+ String.valueOf(in)),null))
						{
							strVS = (String) htParam.get("param_value"
									+ String.valueOf(in));
						}else
							break;
						al.add(in - 1,strVS);
					}
					String sub_code = java.util.Objects.equals(htParam.get("sub_code"),null) ? "" : (String) htParam.get("sub_code");
					String sub_usercode = java.util.Objects.equals(htParam.get("sub_usercode"),null) ? "" : (String) htParam.get("sub_usercode");
					String delay_data = java.util.Objects.equals(htParam.get("delay_data"),null) ? "" : (String) htParam.get("delay_data");
					String delay_code = java.util.Objects.equals(htParam.get("delay_code"),null) ? "" : (String) htParam.get("delay_code");
					String param_name = java.util.Objects.equals(htParam.get("param_name"),null) ? "" : (String) htParam.get("param_name");
					StringBuilder sbd = gd.GetDataList(sub_code,sub_usercode,param_name,al,new StringBuilder(strAryT),delay_data,delay_code,strIP,htParam);
					Send03(sbd.toString(),mServSocket);
				}
			}else if(strAryT.indexOf("@##") == -1
					&& strAryT.indexOf("##@") == -1)
			{
			}
		}
		return "";
	}

	public Hashtable<String, String> GetPackageInfoFlz_1(String strInfo)
	{
		Hashtable<String, String> ht = new Hashtable<String, String>();
		String str1 = "", str2 = "", str3 = "", str4 = "", str5 = "", str6 = "",
				str7 = "", str8 = "", str9 = "", str10 = "", str11 = "",
				str12 = "";
		try
		{
			str1 = strInfo.substring(0,5);
			// M1033 包头
			str2 = strInfo.substring(5,11);
			// RA028A 固定
			str3 = Com_Fun.DateTimeStrYYYYMMDDHHmmss(strInfo.substring(11,23)
					+ "00","yyyyMMddHHmmss");
			// 201910251110 时间
			str4 = strInfo.substring(23,26);
			// K23 负氧离子代码
			str5 = String.valueOf(Integer.valueOf(strInfo.substring(26,31).replace("A","0")));
			// 0114A 负氧离子数据 A表示 *10
			str6 = strInfo.substring(31,36);
			// 0000A 固定
			str7 = strInfo.substring(36,41);
			// M1040 固定
			str8 = strInfo.substring(41,47);
			// RE035E 固定
			str9 = Com_Fun.DateTimeStrYYYYMMDDHHmmss(strInfo.substring(47,59)
					+ "00","yyyyMMddHHmmss");
			// 201910251110 时间
			strInfo = strInfo.substring(strInfo.indexOf("T="),strInfo.length());
			str10 = strInfo.substring(strInfo.indexOf("T=")
					+ 2,strInfo.indexOf("CH="));
			// T=-50.0 温度
			str11 = strInfo.substring(strInfo.indexOf("CH=")
					+ 3,strInfo.indexOf("B=")).replace("%","");
			// CH=99% 湿度
			str12 = strInfo.substring(strInfo.indexOf("B=")
					+ 2,strInfo.indexOf("V"));
			// B=14.2V 电压
			// 回车换行
			ht.put("sub_code","FF0731CC39614C90A5D474BC17253713");
			ht.put("sub_usercode","114A6DB3BBE6419DA3768E6E25127310");
			ht.put("param_name","A01_BCCJ7Y");
			ht.put("param_value1","33082420026260");
			ht.put("1",str1);
			ht.put("2",str2);
			ht.put("param_value2",str3);
			ht.put("4",str4);
			ht.put("param_value3",str5);
			ht.put("param_value4","");
			// 温度
			ht.put("param_value5",str10);
			ht.put("6",str6);
			ht.put("7",str7);
			ht.put("8",str8);
			ht.put("9",str9);
			// 气压
			ht.put("param_value6","");
			// 湿度
			ht.put("param_value7",str11);
			ht.put("12",str12);
			ht.put("param_value8","");
			String strInput_url = "sub_code=FF0731CC39614C90A5D474BC17253713"
					+ "&sub_usercode=114A6DB3BBE6419DA3768E6E25127310"
					+ "&param_name=A01_BCCJ7Y&param_value1=33082420026260"
					+ "&param_value2=" + str3 + "&param_value3=" + str5
					+ "&param_value4=&param_value5=" + str10 + "&param_value6="
					+ "&param_value7=" + str11 + "&param_value8=";
			ht.put("input_url",strInput_url);
		}
		catch(Exception e)
		{
			Com_Fun.debug_in(e,this.toString());
		}
		return ht;
	}

	public Hashtable<String, String> GetPackageInfoFlz(String strInfo)
	{
		Hashtable<String, String> ht = new Hashtable<String, String>();
		int iIndex = 0;
		for(String strs: strInfo.split(","))
		{
			ht.put(String.valueOf(iIndex),strs);
			iIndex++;
		}
		return ht;
	}

	public Hashtable<String, String> GetPackageInfo(String strInfo)
	{
		Hashtable<String, String> ht = new Hashtable<String, String>();
		for(String strs: strInfo.replace("@##","").replace("##@","").split("&"))
		{
			ht.put(strs.split("=")[0],strs.split("=")[1]);
		}
		return ht;
	}

	// 发送TCP/IP数据 字符串形式发送
	public void SendSocket(StringBuilder strInput, Socket sc) throws Exception
	{
		if(DbConfigSelf.UserDebug.indexOf("|10|") != -1)
		{
			StringBuilder sb = new StringBuilder();
			sb.append("通用发送数据包:" + strInput
					+ Com_Fun.DateTimeStr("yyyy-MM-dd HH:mm:ss:SSS"));
			UsAdmin_Log uL = new UsAdmin_Log(Com_Para.ApplicationPath,sb);
			uL.WriteLogSub("SendData");
		}
		sc.setSendBufferSize(1024 * 20);
		BufferedOutputStream bos = null;
		bos = new BufferedOutputStream(sc.getOutputStream());
		bos.write(strInput.toString().getBytes(Com_Para.U_CODE));
		bos.write("\r\n".getBytes(Com_Para.U_CODE));
		bos.flush();

		com.zxy.adminlog.UsAdmin_Log uL = new com.zxy.adminlog.UsAdmin_Log(Com_Para.ApplicationPath,new StringBuilder(sc.getInetAddress().getHostAddress()
				+"|"+String.valueOf(sc.getPort())
				+"=>"+Com_Fun.DateTimeStr("yyyy-MM-dd HH:mm:ss")),"SendEnd");
		uL.WriteLog();
		
		Thread.sleep(500);
	}

	// 发送TCP/IP数据 字节形式发送
	public void SendSocket(char[] bytes, Socket sc) throws Exception
	{
		sc.setSendBufferSize(1024);
		PrintWriter writer = null;
		OutputStreamWriter owr = null;
		owr = new OutputStreamWriter(sc.getOutputStream(),Com_Para.U_CODE);
		writer = new PrintWriter(owr);
		writer.write(bytes,0,bytes.length);
		writer.flush();
		
		Thread.sleep(500);
	}

	public void Send01(Socket sc) throws Exception
	{
		StringBuilder strInput = new StringBuilder();
		strInput.append("@##ST=01&DATATIME="
				+ Com_Fun.DateTimeStr("yyyyMMddHHmmss") + "&CHILD_NODE="
				+ Com_Para.Child_Code + "##@\r\n");
		SendSocket(strInput,sc);
	}

	public void Send02(StringBuilder strUrl, Socket sc) throws Exception
	{
		StringBuilder strInput = new StringBuilder();
		strInput.append("@##ST=02&");
		if(strUrl.toString().indexOf("DATATIME=") != -1)
		{
			strInput.delete(0,strInput.length());
			strInput.append(strUrl.toString());
		}else
			strInput.append("DATATIME=" + Com_Fun.DateTimeStr("yyyyMMddHHmmss")
					+ "&" + strUrl + "##@\r\n");
		SendSocket(strInput,sc);
	}

	public void Send03(String strInfo, Socket sc) throws Exception
	{
		StringBuilder strInput = new StringBuilder();
		strInput.append("@##ST=03&CHILD_NODE=" + Com_Para.Child_Code + "&VALUE="
				+ strInfo + "##@\r\n");
		SendSocket(strInput,sc);
	}

	public void SendReg(Socket sc) throws Exception
	{
		StringBuilder strInput = new StringBuilder();
		strInput.append("@##ST=50&CHILD_NODE=" + Com_Para.Child_Code
				+ "&DEVICE_NAME=" + Com_Para.S_DESC + "##@\r\n");
		SendSocket(strInput,sc);
	}
}